<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@page import="java.util.List"%>
<%@page import="org.apache.commons.lang.xwork.StringUtils"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="com.yaodian100.ec.timelimitsale.entity.TimeLimitMain"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath() %>'/>
<head>
<style type="text/css">
h1 span{visibility:visible;}
</style>
</head>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<script language="javascript">
$().ready( function() {
	$('#sstartDateParam').datepick({minDate: null, showOn:'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd"}); 
	$('#sendDateParam').datepick({minDate: null,beforeShow:customRange,showOn: 'both',numberOfMonths:2, buttonImageOnly: true, buttonImage: '${midContextPath}/images/calendar.gif',dateFormat:"yy-mm-dd"});
	function customRange (){
		var startDt = $('#sstartDateParam').val(); //起始日
		var endDt = new Date(parseInt(startDt.substring(0,4),10),parseInt(startDt.substring(5,7),10)-1,parseInt(startDt.substring(8,10),10)); //結束日
		return {minDate:endDt}; 
	}
});

</script>
<%
@SuppressWarnings("unchecked")
List<TimeLimitMain> timeLimitMainList = (List)request.getAttribute("timeLimitMainList");
TimeLimitMain tlm;
%>
<br />
<h1>限时秒杀管理
<span class="f-link"><a href="${midContextPath}/timeLimitSale/add.do">新增</a></span>
</h1>
<div class="data-form"><s:form action="search.do" method="post">
	<b>活动名称关键字：</b>
	<input name="snameParam" type="text" id="snameParam"
		value="${snameParam}" size="20" maxlength="20">
	<b>搜寻起迄时间：</b>
	<input name="sstartDateParam" type="text" id="sstartDateParam"
		value="${sstartDateParam}" size="10" maxlength="10">
    ~ <input name="sendDateParam" type="text" id="sendDateParam"
		value="${sendDateParam}" size="10" maxlength="10">
	
	上档状态：<s:select name="sshowTypeParam" value="%{sshowTypeParam}" headerKey="" headerValue="全部"
	list="showTypeMenu.options" listKey="key" listValue="value.name" />
	<input type="button" value="搜寻" onClick="this.form.submit();" />
</s:form></div>
<br />
<table class="tb-1"  width="100%">
	<thead>
		<tr>
			<th>#</th>
			<th>日期</th>
			<th>活动名称</th>
			<th>上档状态</th>
			<th>管理</th>
		</tr>
	</thead>
	<tbody>
		<% DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		if(null!=timeLimitMainList)
		for(int i = 0 ; i < timeLimitMainList.size() ; i++){ 
			tlm = timeLimitMainList.get(i);
		%>
			<tr class="<%=i%2==0?"bg-yl":"" %>">
			<td><%=tlm.getId()%></td>
			<td><%=df.format(tlm.getSaleDate())%></td>
			<td><%=tlm.getName()%></td>
			<td>
			<% Date now = new Date();
			if(tlm.getSaleDate().getTime()>now.getTime()){%>
				就绪
			<%}else if(df.format(now).equals(df.format(tlm.getSaleDate()))){%>
				上档中
			<%}else{%>
				已下档
			<%}%></td>
			<td><a href="${midContextPath}/timeLimitSale/edit.do?id=<%=tlm.getId()%>">修改內容</a></td>
			</tr>
		<%} %>
	</tbody>
</table>
<yaodian100:pageutil link="${midContextPath}/timeLimitSale/search.do" pagerObj="${pager}" />